package leecode

func findLonely(nums []int) []int {
	hashMap := make(map[int]int) //key为数组中的元素  , value为出现的次数
	for i := 0; i < len(nums); i++ {
		hashMap[nums[i]]++
	}
	var result []int
	for key, value := range hashMap {
		_, leftOk := hashMap[key-1]
		_, rightOk := hashMap[key+1]
		if value == 1 && !leftOk && !rightOk {
			result = append(result, key)
		}
	}
	return result
}
